package com.ytjj.bigdata.enums;

public enum DynamicExposureTypeEnums {
    EXPOSURE(1, "曝光量"),
    BROWSE(2, "浏览量"),
    INCOME(3, "日收益"),
    URORA(4, "咨询量")
    ;


    private Integer code;

    private String name;

    DynamicExposureTypeEnums(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据枚举code获取名称
     * @param code
     * @return
     */
    public static String getNameByCode(Integer code){
        DynamicExposureTypeEnums[] list = DynamicExposureTypeEnums.values();
        for (DynamicExposureTypeEnums item : list) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return null;
    }

    /**
     * 根据枚举name获取code
     * @param name
     * @return
     */
    public static Integer getCodeByName(String name) {
        DynamicExposureTypeEnums[] values = DynamicExposureTypeEnums.values();
        for (DynamicExposureTypeEnums value : values) {
            if(value.name.equals(name)) {
                return value.getCode();
            }
        }
        return null;
    }
}
